# Copyright 2018- The Pixie Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//bazel:pl_build_system.bzl", "pl_go_test")

go_library(
    name = "controllers",
    srcs = [
        "monitor.go",
        "node_watcher.go",
        "pvc_watcher.go",
        "vizier_controller.go",
    ],
    importpath = "px.dev/pixie/src/operator/controllers",
    visibility = ["//visibility:public"],
    deps = [
        "//src/api/proto/cloudpb:cloudapi_pl_go_proto",
        "//src/api/proto/vizierconfigpb:vizier_pl_go_proto",
        "//src/operator/apis/px.dev/v1alpha1",
        "//src/shared/goversion",
        "//src/shared/services",
        "//src/shared/status",
        "//src/utils/shared/certs",
        "//src/utils/shared/k8s",
        "@com_github_blang_semver//:semver",
        "@com_github_cenkalti_backoff_v4//:backoff",
        "@com_github_gogo_protobuf//types",
        "@com_github_sirupsen_logrus//:logrus",
        "@io_k8s_api//apps/v1:apps",
        "@io_k8s_api//core/v1:core",
        "@io_k8s_api//storage/v1:storage",
        "@io_k8s_apimachinery//pkg/api/errors",
        "@io_k8s_apimachinery//pkg/apis/meta/v1:meta",
        "@io_k8s_apimachinery//pkg/apis/meta/v1/unstructured",
        "@io_k8s_apimachinery//pkg/runtime",
        "@io_k8s_apimachinery//pkg/types",
        "@io_k8s_client_go//informers",
        "@io_k8s_client_go//kubernetes",
        "@io_k8s_client_go//rest",
        "@io_k8s_client_go//tools/cache",
        "@io_k8s_sigs_controller_runtime//:controller-runtime",
        "@io_k8s_sigs_controller_runtime//pkg/client",
        "@org_golang_google_grpc//:grpc",
    ],
)

pl_go_test(
    name = "controllers_test",
    srcs = [
        "monitor_test.go",
        "node_watcher_test.go",
        "pvc_watcher_test.go",
    ],
    embed = [":controllers"],
    deps = [
        "//src/api/proto/cloudpb:cloudapi_pl_go_proto",
        "//src/api/proto/cloudpb/mock",
        "//src/operator/apis/px.dev/v1alpha1",
        "//src/shared/status",
        "@com_github_gogo_protobuf//types",
        "@com_github_golang_mock//gomock",
        "@com_github_stretchr_testify//assert",
        "@io_k8s_api//apps/v1:apps",
        "@io_k8s_api//core/v1:core",
        "@io_k8s_api//storage/v1:storage",
        "@io_k8s_apimachinery//pkg/apis/meta/v1:meta",
        "@io_k8s_apimachinery//pkg/runtime",
        "@io_k8s_apimachinery//pkg/types",
        "@io_k8s_client_go//kubernetes/fake",
        "@io_k8s_client_go//testing",
        "@io_k8s_sigs_controller_runtime//pkg/client",
    ],
)
